local japi = require 'jass.japi'
local mt = ac.buff['弹道']
mt.cover_type = 1
mt.cover_max = 1
mt.level = 1
mt.keep = true
mt.old_missile = ''

function mt:on_add()
    local unit = self.owner
    self.old_missile = unit:get_slk('Missileart','.mdx')
    self.old_speed = tonumber(unit:get_slk('Missilespeed'))
    self.old_arc = tonumber(unit:get_slk('Missilearc'))
    japi.SetUnitMissileArc(unit.handle,self.arc or self.old_arc)
    japi.SetUnitMissileSpeed(unit.handle,self.speed or self.old_speed)
    japi.SetUnitMissileModel(unit.handle,self.model)
end

function mt:on_remove()
    local unit = self.owner
    japi.SetUnitMissileArc(unit.handle,self.old_arc)
    japi.SetUnitMissileSpeed(unit.handle,self.old_speed)
    japi.SetUnitMissileModel(unit.handle,self.old_missile)
end

function mt:on_cover(new)
    return new.level>=self.level
end